// Sidebar Menu Styles
.o_sidebar_menu {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    background-color: #1f2a37;
    color: #f0f4ff;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);

    .o_sidebar_menu_header {
        padding: 15px;
        background-color: rgba(0, 0, 0, 0.2);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        display: flex;
        gap: 12px;
        align-items: center;

        .o_sidebar_menu_collapse_trigger {
            width: 32px;
            height: 32px;
            border-radius: 4px;
            background-color: rgba(255, 255, 255, 0.1);
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: background-color 0.2s ease;
            flex-shrink: 0;
            
            &:hover {
                background-color: rgba(255, 255, 255, 0.2);
            }
            
            i {
                font-size: 16px;
                color: rgba(255, 255, 255, 0.9);
            }
            
            // 折叠状态下的按钮样式
            &.o_sidebar_menu_collapse_trigger_collapsed {
                width: 40px;
                height: 40px;
                margin: 0 auto;
            }
        }

        .o_sidebar_menu_search_wrapper {
            flex: 1;
            display: flex;
            gap: 8px;
            align-items: center;

            .o_sidebar_menu_search_box {
                position: relative;
                flex: 1;

                .o_sidebar_menu_search_clear {
                    position: absolute;
                    right: 8px;
                    top: 50%;
                    transform: translateY(-50%);
                    border: none;
                    background: transparent;
                    color: rgba(255, 255, 255, 0.5);
                    width: 24px;
                    height: 24px;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    cursor: pointer;
                    
                    &:hover {
                        color: rgba(255, 255, 255, 0.8);
                    }
                }
            }
        }

        .o_sidebar_menu_search {
            background-color: rgba(0, 0, 0, 0.2);
            border: 1px solid rgba(255, 255, 255, 0.1);
            color: #f0f4ff;
            border-radius: 4px;
            padding: 8px 12px;
            
            &::placeholder {
                color: rgba(255, 255, 255, 0.5);
            }

            &:focus {
                background-color: rgba(0, 0, 0, 0.3);
                border-color: rgba(255, 255, 255, 0.2);
                color: #f0f4ff;
                outline: none;
                box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
            }
        }
    }

    .o_sidebar_menu_content {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        
        &::-webkit-scrollbar {
            width: 6px;
        }
        
        &::-webkit-scrollbar-track {
            background-color: rgba(255, 255, 255, 0.05);
        }
        
        &::-webkit-scrollbar-thumb {
            background-color: rgba(255, 255, 255, 0.2);
            border-radius: 3px;
            
            &:hover {
                background-color: rgba(255, 255, 255, 0.3);
            }
        }
    }

    .o_sidebar_menu_item {
        padding: 10px 15px;
        cursor: pointer;
        display: flex;
        align-items: center;
        transition: background-color 0.15s ease;
        position: relative;
        
        &:hover {
            background-color: rgba(255, 255, 255, 0.1);
        }

        &.o_sidebar_menu_item_app {
            font-weight: 600;
            font-size: 14px;
            padding: 12px 15px;
            background-color: rgba(0, 0, 0, 0.15);
            margin-bottom: 2px;
        }

        &.o_sidebar_menu_item_expanded {
            background-color: rgba(255, 255, 255, 0.1);
            
            .o_sidebar_menu_toggle {
                transform: rotate(90deg);
            }
        }

        .o_sidebar_menu_toggle {
            margin-left: 8px;
            font-size: 12px;
            transition: transform 0.2s ease;
            width: 24px;
            height: 24px;
            text-align: center;
            color: rgba(255, 255, 255, 0.6);
            border: none;
            background: transparent;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }

        .o_sidebar_menu_icon {
            margin-right: 10px;
            width: 24px;
            height: 24px;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            
            img {
                width: 24px;
                height: 24px;
                object-fit: contain;
            }
        }

        .o_sidebar_menu_name {
            flex: 1;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
    }

    .o_sidebar_menu_children {
        .o_sidebar_menu_item {
            font-size: 13px;
            padding-top: 8px;
            padding-bottom: 8px;
            border-left: 2px solid transparent;
            
            &:hover {
                border-left-color: rgba(255, 255, 255, 0.3);
            }
        }
    }
}

// Adjust main content when sidebar is shown
body:has(.o_sidebar_menu) {
    .o_action_manager {
        margin-left: 280px;
        transition: margin-left 0.3s ease;
    }
    
    // 标签页栏也需要调整位置
    .o_tab_manager_bar {
        left: 280px;
        transition: left 0.3s ease;
    }
    
    .o_main_navbar {
        margin-left: 280px;
        transition: margin-left 0.3s ease;

        .o_menu_sections,
        .o_menu_brand {
            display: none;
        }

        .o_menu_systray {
            display: flex;
        }
    }
}

// 侧边栏收起时的调整
body:has(.o_sidebar_menu_collapsed) {
    .o_action_manager {
        margin-left: 72px;
    }
    
    .o_tab_manager_bar {
        left: 72px;
    }
    
    .o_main_navbar {
        margin-left: 72px;
    }
}

.o_sidebar_menu_collapsed {
    width: 72px;

    .o_sidebar_menu_header {
        justify-content: center;
        padding: 15px 8px;
    }

    .o_sidebar_menu_search_wrapper {
        display: none;
    }

    .o_sidebar_menu_content {
        .o_sidebar_menu_item {
            justify-content: center;
            padding: 12px 8px;
        }
        
        .o_sidebar_menu_item_app {
            padding: 14px 8px;
        }
        
        .o_sidebar_menu_icon {
            margin-right: 0;
        }
        
        .o_sidebar_menu_name {
            display: none;
        }

        .o_sidebar_menu_toggle {
            display: none;
        }
    }
}

.o_sidebar_flyout {
    position: absolute;
    width: 240px;
    max-height: 80vh;
    background: #1f2a37;
    color: #f0f4ff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    border-radius: 8px;
    z-index: 1100;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    transition: opacity 0.2s ease;

    .o_sidebar_flyout_header {
        padding: 8px 16px;
        font-weight: 600;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        margin-bottom: 4px;
        flex-shrink: 0;
    }

    .o_sidebar_flyout_list {
        overflow-y: auto;
        overflow-x: hidden;
        max-height: calc(80vh - 50px);
        
        &::-webkit-scrollbar {
            width: 6px;
        }
        
        &::-webkit-scrollbar-track {
            background-color: rgba(255, 255, 255, 0.05);
        }
        
        &::-webkit-scrollbar-thumb {
            background-color: rgba(255, 255, 255, 0.2);
            border-radius: 3px;
            
            &:hover {
                background-color: rgba(255, 255, 255, 0.3);
            }
        }
        
        .o_sidebar_menu_item {
            padding: 10px 16px;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 8px;
            transition: background-color 0.15s ease;

            &:hover {
                background: rgba(255, 255, 255, 0.1);
            }
            
            .o_sidebar_menu_name {
                flex: 1;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
            }
            
            .fa-chevron-right {
                flex-shrink: 0;
                transition: transform 0.2s ease;
            }
            
            &:hover .fa-chevron-right {
                transform: translateX(2px);
            }
        }
    }
}

.o_sidebar_flyout_backdrop {
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 1090;
}

// Tab Manager Styles  
.o_tab_manager_bar {
    position: fixed;
    top: 48px; // 在顶部导航栏下方
    left: 0;
    right: 0;
    background: linear-gradient(to bottom, #ffffff 0%, #f8f9fa 100%);
    border-bottom: 1px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: flex-end;
    min-height: 44px;
    max-height: 44px;
    overflow-x: auto;
    overflow-y: hidden;
    z-index: 998; // 低于顶部菜单栏
    padding: 0 12px;

    &::-webkit-scrollbar {
        height: 3px;
    }

    &::-webkit-scrollbar-track {
        background-color: transparent;
    }

    &::-webkit-scrollbar-thumb {
        background-color: #ced4da;
        border-radius: 2px;
        
        &:hover {
            background-color: #adb5bd;
        }
    }

    .o_tab_manager_tabs {
        display: flex;
        flex-direction: row;
        align-items: flex-end;
        gap: 4px;
        flex: 1;
        min-width: 0;
        height: 100%;
    }

    .o_tab_manager_tab {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 10px;
        padding: 10px 18px;
        background-color: #e9ecef;
        border: 1px solid #dee2e6;
        border-bottom: none;
        border-radius: 8px 8px 0 0;
        cursor: pointer;
        min-width: 160px;
        max-width: 240px;
        height: 38px;
        transition: all 0.2s ease;
        margin-bottom: 1px;
        position: relative;
        white-space: nowrap;
        box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.05);
        
        &:hover:not(.o_tab_manager_tab_active) {
            background-color: #f1f3f5;
            transform: translateY(-1px);
            box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.08);
        }

        &.o_tab_manager_tab_active {
            background: linear-gradient(to bottom, #ffffff 0%, #f8f9fa 100%);
            border-color: #dee2e6;
            border-bottom: 2px solid #f8f9fa;
            margin-bottom: -1px;
            height: 40px;
            box-shadow: 0 -3px 8px rgba(0, 0, 0, 0.12);
            z-index: 1;
            
            .o_tab_manager_tab_title {
                font-weight: 600;
                color: #212529;
            }
            
            .o_tab_manager_tab_icon {
                border-color: #0d6efd;
                background-color: #0d6efd;
            }
        }
        
        .o_tab_manager_tab_icon {
            font-size: 14px;
            color: #6c757d;
            flex-shrink: 0;
            width: 10px;
            height: 10px;
            border: 2px solid #6c757d;
            border-radius: 50%;
            background-color: transparent;
            transition: all 0.2s ease;
            
            // 空心圆圈，不显示 font icon
            &::before {
                content: '';
                display: none;
            }
        }

        .o_tab_manager_tab_title {
            flex: 1;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            font-size: 13px;
            color: #495057;
            line-height: 1.4;
        }

        .o_tab_manager_tab_close {
            font-size: 16px;
            color: #adb5bd;
            width: 20px;
            height: 20px;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            transition: all 0.15s ease;
            
            &:hover {
                background-color: #dc3545;
                color: white;
                transform: scale(1.1);
            }
        }
    }
}

// 当有标签页时，给 ActionContainer 留出空间（顶部菜单 48px + 标签页 44px）
body:has(.o_tab_manager_bar) {
    .o_action_manager {
        margin-top: 92px;
    }
}

// Responsive adjustments
@media (max-width: 768px) {
    .o_sidebar_menu {
        width: 240px;
    }
    
    body:has(.o_sidebar_menu) {
        .o_action_manager {
            margin-left: 240px;
        }
    }
}

